Transformer Discharge Carbon-Trace Detection Based on Improved MSRCR Image-Enhancement Algorithm and YOLOv8 Model

It is difficult to visually detect internal defects in a large transformer with a metal closure. For convenient internal inspection, a micro-robot was adopted, and an inspection method based on an image-enhancement algorithm and an improved deep-learning network was proposed in this paper. Considering the dim environment inside the transformer and the problems of irregular imaging distance and fluctuating supplementary light conditions during image acquisition with the internal-inspection robot, an improved MSRCR algorithm for image enhancement was proposed. It could analyze the local contrast of the image and enhance the details on multiple scales. At the same time, a white-balance algorithm was introduced to enhance the contrast and brightness and solve the problems of overexposure and color distortion. To improve the target recognition performance of complex carbon-trace defects, the SimAM mechanism was incorporated into the Backbone network of the YOLOv8 model to enhance the extraction of carbon-trace features. Meanwhile, the DyHead dynamic detection Head framework was constructed at the output of the YOLOv8 model to improve the perception of local carbon traces with different sizes. To improve the defect target recognition speed of the transformer-inspection robot, a pruning operation was carried out on the YOLOv8 model to remove redundant parameters, realize model lightness, and improve detection efficiency. To verify the effectiveness of the improved algorithm, the detection model was trained and validated with the carbon-trace dataset. The results showed that the MSH-YOLOv8 algorithm achieved an accuracy of 91.80%, which was 3.4 percentage points higher compared to the original YOLOv8 algorithm, and had a significant advantage over other mainstream target-detection algorithms. Meanwhile, the FPS of the proposed algorithm was up to 99.2, indicating that the model computation and model complexity were successfully reduced, which meets the requirements for engineering applications of the transformer internal-inspection robot.


Introduction
As the core equipment of the power grid, the operating condition of large transformers is directly related to the stable operation of the power grid.The metal-enclosed nature of the transformer leads to poor internal visibility, and it is difficult to accurately determine the location, type, and severity of internal defects in the transformer only by analyzing the dissolved gases in the oil (e.g., the three-ratio method, the modified three-ratio method, etc.) [1][2][3][4][5][6][7][8].To determine the internal defects of the transformer, manual drilling into the transformer or lifting the cover is often used for inspection, but this method has the problems of low efficiency, poor accuracy, high risk, and high cost.With the development of robotics and artificial intelligence, micro-robots can be utilized to enter the interior of large • When the moving internal-inspection robot acquires images in the dark environment inside the transformer, there are unfavorable conditions such as irregular imaging distance and fluctuating supplemental light conditions, which lead to the problems of large differences in image quality, blurred images, and inconspicuous carbontrace features.In this paper, an improved MSRCR image-enhancement algorithm is proposed.By enhancing the contrast of the image at multiple scales, highlighting the image details and structure, and fusing the multiple-scale components according to a certain weighting while introducing a white-balance algorithm to improve the brightness overexposure and color distortion problems, the brightness and contrast of the picture are enhanced.• To improve the performance of complex carbon-trace target recognition, this paper incorporates the SimAM module into the Backbone network of the YOLOv8 deep-learning network model to enhance the ability to extract carbon-trace features.At the same time, the DyHead dynamic detection head framework is constructed at the output of the YOLOv8 model to enhance the ability to sense localized carbon traces with different sizes and further improve the accuracy and robustness of defect detection.• To improve the recognition speed of the fast-moving transformer internal-inspection robot, this paper performs a pruning operation on the YOLOv8 deep-learning network model, removing redundant parameters and realizing model lightness.Through pruning optimization, the improved network significantly improves detection efficiency and meets the real-time requirements of engineering applications.

Structure of the Transformer Internal-Inspection Robot
The inspection robot mainly includes the main body, ultrasonic emission module, image-acquisition device, ultrasonic ranging module, vertical propeller propulsion device, horizontal propeller propulsion device, pressure sensor, and robot control system.The main body of the robot is an elliptical sealed structure, and the ultrasonic emission module is installed at the top of the main body, which is mainly used for the three-dimensional positioning of the inspection robot.An image-acquisition device is installed on the upper part of the robot body, which can be used to inspect the insulation condition inside the transformer as well as the surrounding obstacles.Four ultrasonic ranging modules are installed around the robot body, which can be used to measure the distance of the surrounding obstacles.Two vertical propeller thrusters are installed in the middle and lower part of the robot body, which can control the upward and downward movement of the robot body.Two horizontal propeller propulsion devices are installed in the lower part of the robot body, which can control the forward movement and rotation of the inspection robot body.A depth pressure sensor is installed at the bottom of the robot body, which can be used to measure the diving depth of the inspection robot.There is a control system inside the robot body, which mainly includes a motor drive and control module, data acquisition module, position detection module, wireless transmission module, and power-supply module.Its structure is shown in Figure 1.
brightness overexposure and color distortion problems, the brightness and contrast of the picture are enhanced.

•
To improve the performance of complex carbon-trace target recognition, this paper incorporates the SimAM module into the Backbone network of the YOLOv8 deeplearning network model to enhance the ability to extract carbon-trace features.At the same time, the DyHead dynamic detection head framework is constructed at the output of the YOLOv8 model to enhance the ability to sense localized carbon traces with different sizes and further improve the accuracy and robustness of defect detection.

•
To improve the recognition speed of the fast-moving transformer internal-inspection robot, this paper performs a pruning operation on the YOLOv8 deep-learning network model, removing redundant parameters and realizing model lightness.
Through pruning optimization, the improved network significantly improves detection efficiency and meets the real-time requirements of engineering applications.

Structure of the Transformer Internal-Inspection Robot
The inspection robot mainly includes the main body, ultrasonic emission module, image-acquisition device, ultrasonic ranging module, vertical propeller propulsion device, horizontal propeller propulsion device, pressure sensor, and robot control system.The main body of the robot is an elliptical sealed structure, and the ultrasonic emission module is installed at the top of the main body, which is mainly used for the three-dimensional positioning of the inspection robot.An image-acquisition device is installed on the upper part of the robot body, which can be used to inspect the insulation condition inside the transformer as well as the surrounding obstacles.Four ultrasonic ranging modules are installed around the robot body, which can be used to measure the distance of the surrounding obstacles.Two vertical propeller thrusters are installed in the middle and lower part of the robot body, which can control the upward and downward movement of the robot body.Two horizontal propeller propulsion devices are installed in the lower part of the robot body, which can control the forward movement and rotation of the inspection robot body.A depth pressure sensor is installed at the bottom of the robot body, which can be used to measure the diving depth of the inspection robot.There is a control system inside the robot body, which mainly includes a motor drive and control module, data acquisition module, position detection module, wireless transmission module, and powersupply module.Its structure is shown in Figure 1.The prototype of the transformer-inspection robot is made of aluminum alloy.The sealing and movement performance of the robot were tested in the previous period.In Sensors 2024, 24, 4309 4 of 17 addition, it has initially realized the functions of floating up and sinking down, horizontal 360-degree rotation, forward and backward in the transformer oil.
During the moving process in the transformer oil, the image-acquisition module of the robot continuously captures the internal environment, and the collected internal image data are wirelessly transmitted to the external computer, thus completing the visual identification of transformer defects.The sample library constructed in this paper was the discharge carbon-trace defects, which are generated with partial discharge occurring on the surface of the transformer insulation enclosure, including dendritic carbon-trace defects and agglomerated creepage carbon-trace defects.A needle-plate model test platform was constructed in this paper to construct the carbon-trace sample library, which mainly included a specimen model, a boosting platform, and a high-speed camera.The specimen model was mainly composed of nylon screw, acrylic board, nylon bracket, front electrode, equalizing ring, and connecting rod.Its structure is shown in Figure 2. The transformer cardboard was uniformly cut to the size of 25 cm × 15 cm, and the nylon bracket was used to fix the cardboard on the acrylic board and the inclination angle of the cardboard was changed by replacing the bracket with different angles.The test transformer was SB-10KVA/100KV, and the sample container was made of acrylic, which was transparent and made it easy to observe the test phenomenon.The transformer oil used for the test was Kelamayi No. 25 transformer oil.The high-speed camera was HTSUA134GC/M, with 1.3 million pixels and a frame rate of 211FPS.Its structure is shown in Figure 3.

Sample Library
The partial discharge was generated using the test setup described above, and the camera was used to photograph, record, and upload the test phenomena to the computer.After many tests, a sample library of carbon-trace defects in the transformer enclosure screen was produced.As shown in Figure 4.
The prototype of the transformer-inspection robot is made of aluminum al sealing and movement performance of the robot were tested in the previous pe addition, it has initially realized the functions of floating up and sinking down, ho 360-degree rotation, forward and backward in the transformer oil.
During the moving process in the transformer oil, the image-acquisition m the robot continuously captures the internal environment, and the collected inte age data are wirelessly transmitted to the external computer, thus completing th identification of transformer defects.The sample library constructed in this paper was the discharge carbon-trace which are generated with partial discharge occurring on the surface of the tran insulation enclosure, including dendritic carbon-trace defects and agglomerated c carbon-trace defects.A needle-plate model test platform was constructed in this construct the carbon-trace sample library, which mainly included a specimen m boosting platform, and a high-speed camera.The specimen model was mainly co of nylon screw, acrylic board, nylon bracket, front electrode, equalizing ring, and c ing rod.Its structure is shown in Figure 2. The transformer cardboard was unifor to the size of 25 cm × 15 cm, and the nylon bracket was used to fix the cardboar acrylic board and the inclination angle of the cardboard was changed by repla bracket with different angles.The test transformer was SB-10KVA/100KV, and the container was made of acrylic, which was transparent and made it easy to observe phenomenon.The transformer oil used for the test was Kelamayi No. 25 transfor The high-speed camera was HTSUA134GC/M, with 1.3 million pixels and a fram 211FPS.Its structure is shown in Figure 3.The partial discharge was generated using the test setup described above, and the camera was used to photograph, record, and upload the test phenomena to the computer.After many tests, a sample library of carbon-trace defects in the transformer enclosure screen was produced.As shown in Figure 4.

Preprocessing for Image Feature Enhancement
In the closed internal environment of the transformer, ambient light, noise, and other disturbing factors lead to poor-quality images captured by the internal-inspection robot and the inconspicuousness of carbon-trace features.This would cause trouble with subsequent image processing and feature extraction, reducing the visibility and identification accuracy of fault defects.
Image preprocessing was performed using the MSRCR algorithm to address the problems associated with the local carbon-trace images.The MSRCR algorithm is an image-enhancement method based on the Retinex theory, which performs localized contrast enhancement of an image while ensuring that the global contrast of the image remains unchanged, thus avoiding over-sharpening and enhancing the image brightness at the same time [17].An image is represented as the product of the illumination component and the reflection component based on the Retinex theory [18]:  The partial discharge was generated using the test setup described above, and the camera was used to photograph, record, and upload the test phenomena to the computer.After many tests, a sample library of carbon-trace defects in the transformer enclosure screen was produced.As shown in Figure 4.

Preprocessing for Image Feature Enhancement
In the closed internal environment of the transformer, ambient light, noise, and other disturbing factors lead to poor-quality images captured by the internal-inspection robot and the inconspicuousness of carbon-trace features.This would cause trouble with subsequent image processing and feature extraction, reducing the visibility and identification accuracy of fault defects.
Image preprocessing was performed using the MSRCR algorithm to address the problems associated with the local carbon-trace images.The MSRCR algorithm is an image-enhancement method based on the Retinex theory, which performs localized contrast enhancement of an image while ensuring that the global contrast of the image remains unchanged, thus avoiding over-sharpening and enhancing the image brightness at the same time [17].An image is represented as the product of the illumination component and the reflection component based on the Retinex theory [18]:

Preprocessing for Image Feature Enhancement
In the closed internal environment of the transformer, ambient light, noise, and other disturbing factors lead to poor-quality images captured by the internal-inspection robot and the inconspicuousness of carbon-trace features.This would cause trouble with subsequent image processing and feature extraction, reducing the visibility and identification accuracy of fault defects.
Image preprocessing was performed using the MSRCR algorithm to address the problems associated with the local carbon-trace images.The MSRCR algorithm is an imageenhancement method based on the Retinex theory, which performs localized contrast enhancement of an image while ensuring that the global contrast of the image remains unchanged, thus avoiding over-sharpening and enhancing the image brightness at the same time [17].An image is represented as the product of the illumination component and the reflection component based on the Retinex theory [18]: where I(x, y) denotes the original image, L(x, y) is the illuminance component and R(x, y) is the reflectance component.Retinex theory suggests that the color perceived by the human visual system depends mainly on the reflection component.For an original image I(x, y), the calculated result R(x, y) is the enhanced image.The illuminance component L(x, y) can be obtained by Gaussian blurring the original data.
The MSRCR algorithm is based on the multi-scale Retinex image-enhancement algorithm by introducing a color recovery factor, which compensates for the color distortion caused by image enhancement as well as the problem of grayish tones, whose expression is: where I i (x, y) is the input image, ω n is the weighting coefficient of the nth scale; F n (x, y) is the Gaussian filter function at the nth scale.C i (x, y) is the color recovery factor, whose expression is where β is the gain function set to 5, and α is the non-linear strength set to 0.5.
Test results revealed that the images enhanced by the MSRCR algorithm suffered from overexposure and color distortion.To solve this problem, an improved MSRCR image-enhancement algorithm incorporating white balance was proposed in this paper.The principle of white balance is based on the grayscale world assumption and luminance invariance assumption.The grayscale world assumption holds that the average grayscale of all colors in an image should be equal under average illumination.The luminance invariance assumption holds that the luminance of an image should remain constant under different lighting conditions.Based on these assumptions, the goal of white balance is to make the average gray value of each channel in the image equal to eliminate the color bias [19], and the calculation formula is shown below.white_balance = ( max_avg power channel_avg power (4) where white_balance is the white-balance coefficient, max_avg is the maximum value of the average brightness of all channels in the image, channel_avg is the average brightness of each channel in the image.According to the white-balance coefficient, readjust the RGB channel values to solve the problem of brightness overexposure and color distortion.As shown in Figure 5, the quantization results of the images before and after the enhancement in terms of brightness and contrast were presented.The brightness of the image enhanced by the MSRCR algorithm was concentrated around 170, which was too high and led to color distortion of the carbon-trace features and affected the image contrast.After the introduction of the improved MSRCR algorithm processing of white balance, the brightness of the image was improved, and the brightness value was concentrated at about 100 and uniformly distributed, which effectively improved the problem of overexposure and color distortion caused by too high brightness in the image after enhancement by the MSRCR algorithm.The histogram showed that the grayscale values of the improved image were more evenly distributed, indicating that the contrast has been significantly improved compared to the original algorithm.

The Improved Target-Detection Model Based on YOLOv8
Yolov8 is an updated version of the Yolo series algorithms, which has been w used in the field of visual target detection.Yolov8 mainly consists of three parts: Back Neck, and Head.The Backbone network is used to extract defective features for use subsequent networks.The Neck network fuses features extracted from different le the Backbone network to extract higher-level features.The Head network makes p tions based on the output features of the front network to obtain the final predicti sults.The improved YOLOv8 network structure is shown in Figure 6.

The Improved Target-Detection Model Based on YOLOv8
Yolov8 is an updated version of the Yolo series algorithms, which has been widely used in the field of visual target detection.Yolov8 mainly consists of three parts: Backbone, Neck, and Head.The Backbone network is used to extract defective features for use by the subsequent networks.The Neck network fuses features extracted from different levels in the Backbone network to extract higher-level features.The Head network makes predictions based on the output features of the front network to obtain the final prediction results.The improved YOLOv8 network structure is shown in Figure 6.
After the carbon-trace image is input into the network architecture, the carbon-trace defect features, such as texture, shape, and color of the defects, are first extracted by several modules consisting of convolution and pooling layers; then the extracted defect features are fused and enhanced using the feature pyramid module to obtain more comprehensive defect information.Then, the above defect information will be transferred to the header network to perform classification and prediction, locate the defect positions, and classify the defect types.Finally, after the post-processing operation, the detection result is optimized to ensure that each defect is complete and only once labeled.After the carbon-trace image is input into the network architecture, the carbon-trace defect features, such as texture, shape, and color of the defects, are first extracted by several modules consisting of convolution and pooling layers; then the extracted defect features are fused and enhanced using the feature pyramid module to obtain more comprehensive defect information.Then, the above defect information will be transferred to the header network to perform classification and prediction, locate the defect positions, and classify the defect types.Finally, after the post-processing operation, the detection result is optimized to ensure that each defect is complete and only once labeled.
The existing Yolov8 algorithm has problems with leakage and false detection in the face of the complex background inside the transformer and the complexity of the carbontrace features in the transformer, which are of various sizes and without any regularity.To solve this problem and further improve the defect detection efficiency of the improved model, this paper mainly focused on the improvement of three aspects: attention mechanism, target-detection Head, and model pruning.

SimAM Attention Mechanism
To improve the ability to extract carbon-trace features, an attention mechanism is introduced into the Backbone network.Most of the existing attention modules focus on the channel or spatial domain, generate one-or two-dimensional weights, and treat neurons in each channel or spatial location equally, which limits the ability to learn more discriminative cues [20].Inspired by the attention mechanism of the human brain, an attention model with full three-dimensional weights was proposed by combining the two mechanisms in the channel and spatial domains, and an energy function was designed to compute and assign the weights to each neuron.
SimAM evaluates the importance of individual neurons by measuring the linear separability between a target neuron and other neurons and defines the following energy function for each neuron: The existing Yolov8 algorithm has problems with leakage and false detection in the face of the complex background inside the transformer and the complexity of the carbon-trace features in the transformer, which are of various sizes and without any regularity.To solve this problem and further improve the defect detection efficiency of the improved model, this paper mainly focused on the improvement of three aspects: attention mechanism, target-detection Head, and model pruning.

SimAM Attention Mechanism
To improve the ability to extract carbon-trace features, an attention mechanism is introduced into the Backbone network.Most of the existing attention modules focus on the channel or spatial domain, generate one-or two-dimensional weights, and treat neurons in each channel or spatial location equally, which limits the ability to learn more discriminative cues [20].Inspired by the attention mechanism of the human brain, an attention model with full three-dimensional weights was proposed by combining the two mechanisms in the channel and spatial domains, and an energy function was designed to compute and assign the weights to each neuron.
SimAM evaluates the importance of individual neurons by measuring the linear separability between a target neuron and other neurons and defines the following energy function for each neuron: where t = ω t t + b t and xi = ω t x i + b t are linear transformations of t and x i , and X ∈ R C×H×W is the input features of t and i, i is the index in the spatial dimension, M = H × W are the number of neurons in the channel, ω t and b t are the weighted and biased transformations, respectively.When t and y t reach the minimum values at the same time, Sensors 2024, 24, 4309 9 of 17 the above equation is equivalent to finding the linear separability between the target neuron t and all other neurons in the same channel.Using binary labels (i.e., 1 and −1) for y t and y o , introducing a regularization factor and assuming that the mean and variance can be computed on all neurons, reapply it to all neurons on that channel to obtain a minimum energy formula: where The above equation shows that at lower energies, the neuron becomes more distinct from the peripheral neurons.Therefore, the importance of each neuron can be obtained with 1/e * t .Finally, the final weight of each neuron is obtained by scaling: where X and X denote the input and output feature maps, and E is an energy matrix containing the energy value of each element in the input feature map X.The energy inverse is compressed using the Sigmoid function to limit its value to between 0 and 1.This is to avoid excessively large energy values while maintaining the relative importance of each pixel or neuron.Its structure is shown in Figure 7.
is the input features of t and i , i is the index in the spatial dimension, M H W = are the number of neurons in the channel, t  and t b are the weighted and biased transformations, respectively.When t and t y reach the minimum values at the same time, the above equation is equivalent to finding the linear separability between the target neuron t and all other neurons in the same channel.
Using binary labels (i.e., 1 and −1) for t y and y o , introducing a regularization factor and assuming that the mean and variance can be computed on all neurons, reapply it to all neurons on that channel to obtain a minimum energy formula: where The above equation shows that at lower energies, the neuron becomes more distinct from the peripheral neurons.Therefore, the importance of each neuron can be obtained with * 1/ t e .Finally, the final weight of each neuron is obtained by scaling: where X and X denote the input and output feature maps, and E is an energy ma- trix containing the energy value of each element in the input feature map .The energy inverse is compressed using the Sigmoid function to limit its value to between 0 and 1.This is to avoid excessively large energy values while maintaining the relative importance of each pixel or neuron.Its structure is shown in Figure 7.

Head Frame for Self-Attentive Dynamic Detection
A Backbone network responsible for feature extraction and a Head detection network responsible for localization and classification are common design ideas in current targetdetection technologies.Therefore, enhancing the performance of the Head network becomes one of the keys to improving the accuracy of target detection.As an innovative, dynamic detection Head framework, the DyHead dramatically enhances the characterization capability of the detection Head by integrating three self-attention mechanisms with different dimensions (level, spatial, and channel), i.e., scale-awareness, space-awareness, and task-awareness mechanisms [21].The scale-aware mechanism focuses on the

Head Frame for Self-Attentive Dynamic Detection
A Backbone network responsible for feature extraction and a Head detection network responsible for localization and classification are common design ideas in current target-detection technologies.Therefore, enhancing the performance of the Head network becomes one of the keys to improving the accuracy of target detection.As an innovative, dynamic detection Head framework, the DyHead dramatically enhances the characterization capability of the detection Head by integrating three self-attention mechanisms with different dimensions (level, spatial, and channel), i.e., scale-awareness, space-awareness, and task-awareness mechanisms [21].The scale-aware mechanism focuses on the level dimension and enhances the scale characterization of a specific layer by assessing the importance of different semantic dimensions, computed as: where F represents the input feature map, S represents the spatial dimension, C represents the number of channels, and σ is a hard-sigmoid function to limit the attention weight range between 0 and 1.
The spatial perception mechanism is then deployed in the spatial dimension (height × width) and works to learn coherent and discriminative feature representations across spatial locations, computed as: where K is the number of sparsely sampled locations, p k + ∆p k is the self-learning spatial offset, and ∆m k is a scalar of the self-learning importance at the location p k .The task-aware mechanism runs through the channel dimensions, guiding different feature channels to support their respective tasks (e.g., classification, regression, and center/keypoint detection).Based on the object-specific convolutional kernel response, it is computed as: where is the hyperfunction of the learning control activation threshold.
By decomposing the attentional process into three separate dimensions, each focusing on one perspective, DyHead achieves an effective unification of the target-detection Head and the attentional mechanism: where F is the three-dimensional feature tensor and π L (•), π S (•), π C (•) is the attention function applied to the three dimensions L, S, C, respectively.The above three attention mechanisms are sequentially connected in the model line and repeatedly stacked to form the DyHead module, the structure of which is shown in Figure 8.
The spatial perception mechanism is then deployed in the spatial dimension (height × width) and works to learn coherent and discriminative feature representations across spatial locations, computed as: where K is the number of sparsely sampled locations, kk pp + is the self-learning spa- tial offset, and k m  is a scalar of the self-learning importance at the location k p .
The task-aware mechanism runs through the channel dimensions, guiding different feature channels to support their respective tasks (e.g., classification, regression, and center/keypoint detection).Based on the object-specific convolutional kernel response, it is computed as: where = is the hyperfunction of the learning control activation threshold.
By decomposing the attentional process into three separate dimensions, each focusing on one perspective, DyHead achieves an effective unification of the target-detection Head and the attentional mechanism: where F is the three-dimensional feature tensor and ()   is the atten- tion function applied to the three dimensions ,, L S C , respectively.The above three atten- tion mechanisms are sequentially connected in the model line and repeatedly stacked to form the DyHead module, the structure of which is shown in Figure 8.In this paper, the DyHead module was integrated into the detection Head network of Yolov8, which can be integrated into a target-detection Head by effectively combining multiple self-attentive attention mechanisms across feature layers, enabling it to learn the relative importance between feature layers and enhancing the feature-enhanced perception of localized carbon traces with different sizes on the corresponding layers.

Lightweight Pruning for Model Optimization
To improve the detection speed of the improved model, make the model lighter, reduce overfitting, and enhance the interpretability of the model, a global pruning algorithm, LAMP, was adopted in this paper, which is based on the computation of importance scores [22].The principle is to calculate the size of the target connection square weights and then normalize them by the sum of all the "surviving weights" in the layer.Suppose that the weight tensor of each fully connected or convolutional layer is expanded into a one-dimensional vector, and these weights are sorted by a given index term, where the LAMP score of the first index of the weight tensor is defined as: where W denotes the weight, W[u] and W[v] are the weight terms mapped by indexes u and v, respectively, after ascending order.The LAMP score is used to evaluate the relative importance of all surviving connections in the same layer.Once the score is determined, connections with smaller weight sizes (in the same layer) need to be pruned until the desired global sparsity constraint is satisfied.The pruning process is shown in Figure 9.
Suppose that the weight tensor of each fully connected or convolutional layer is expanded into a one-dimensional vector, and these weights are sorted by a given index term, where the LAMP score of the first index of the weight tensor is defined as: where W denotes the weight, [] Wu and [] Wv are the weight terms mapped by in- dexes u and v , respectively, after ascending order.
The LAMP score is used to evaluate the relative importance of all surviving connections in the same layer.Once the score is determined, connections with smaller weight sizes (in the same layer) need to be pruned until the desired global sparsity constraint is satisfied.The pruning process is shown in Figure 9.The specific process of the LAMP pruning algorithm is: (1) According to the improved yolov8 network architecture, train the network to obtain the weight file of the training results.(2) According to the weight file, the LAMP scores of each connection in each layer are calculated, and the connections with lower scores in each layer are selected to be pruned according to the preset global sparsity requirements.( 3) Retrain the pruned model to restore the model to its pre-pruning performance.(4) Evaluate the performance of the retrained model.

Calibration of Samples
Data expansion was performed on the carbon-trace samples obtained from the indoor experiment, and a total of 6253 images were obtained.The images were divided according to the training set:validation set:dataset ratio of 8:1:1 after data preprocessing, and the dataset was labeled using LabelImg.The specific process of the LAMP pruning algorithm is: (1) According to the improved yolov8 network architecture, train the network to obtain the weight file of the training results.(2) According to the weight file, the LAMP scores of each connection in each layer are calculated, and the connections with lower scores in each layer are selected to be pruned according to the preset global sparsity requirements.( 3) Retrain the pruned model to restore the model to its pre-pruning performance.( 4) Evaluate the performance of the retrained model.

Calibration of Samples
Data expansion was performed on the carbon-trace samples obtained from the indoor experiment, and a total of 6253 images were obtained.The images were divided according to the training set:validation set:dataset ratio of 8:1:1 after data preprocessing, and the dataset was labeled using LabelImg.

Test Platform Parameters and Evaluation Indexes
The model-training environment is Windows 11, the CPU model is Intel Corei5-13400F, and the GPU model is NVIDIA GeForce 4060ti, with 16 GB of video memory.The deeplearning framework is PyTorch 2.1.0,and the Python version is 3.8.The training parameters are set as follows: stochastic gradient descent (SGD) is used as the optimizer, the initial learning rate is set to 0.01, and the number of training rounds is set to 200 epochs.
To evaluate the performance of the algorithm, it is necessary to select appropriate evaluation indices.In this paper, mean Average Precision (mAP) is selected as the evaluation index.The higher the mAP, the better the algorithm's performance in both checking accuracy and checking completeness [23].First, the precision (P) and recall (R) of the prediction frames of each category above the threshold of the intersection over the union (IoU) are calculated, respectively, where TP denotes the number of correctly identified positive samples, FP denotes the number of negative samples identified as positive samples, FN denotes the number of positive samples incorrectly identified as negative samples, TN denotes the number of negative samples correctly identified.The calculation results of the checking accuracy and the checking completeness constitute the P-R curve.
For each category, its Average Precision (AP), which is the area below the P-R curve, is calculated [16].For each category, the maximum value of AP is taken as the AP value for that category.Finally, the AP values of all categories were averaged to obtain the final mAP value.

Ablation Experiment
To further verify the effectiveness of the attention mechanism SimAM and the selfattention detection head network DyHead, ablation experiments were carried out with YOLOv8n as the benchmark.The optimal results in the training rounds are selected for comparison, and the test results are shown in Table 1, where √ indicates that the improved method is used.As shown in Table 1, compared with the baseline model, the mAP of the improved models gradually increased.After the addition of the SimAM attention mechanism, the recall rate R increased by 0.025, and the mAP increased by 0.020; after the introduction of the DyHead self-attentive dynamic monitoring Head, the precision rate P increased by 0.015, the recall rate R increased by 0.019, and the mAP increased by 0.030.Finally, under the joint effect of SimAM and DyHead, the precision rate and the recall rate were both effectively improved, and mAP was improved by 0.037, in which the precision of dendritic carbon-trace recognition was improved by 0.051, and the precision of clumpy carbon-trace detection was improved by 0.024.
To verify the performance of the proposed algorithm in a real environment, this paper collected real images of large transformers after partial discharges occurred inside them for carbon-trace identification and localization.The results shown in Figure 10 illustrate the ability of the algorithm to effectively detect authentic carbon traces inside the transformers, even under complex background scenarios.This demonstrated the practical effectiveness of the algorithm proposed in this paper.

Comparative Experiments with Model Pruning
Since there are some layers in the network architecture whose data are very important for the whole network, pruning these layers will lose the relevant data and lead to a significant degradation of the model performance.Therefore, before pruning the model, the model needs to be processed by layer hopping.In this paper, layer hopping was applied to the output layer of the detection Head network.
Then, the improved model was pruned, and the results of pruning are shown in Table 2, where the parameter speed_up was used to set the degree of pruning.The larger the speed_up, the larger the degree of pruning of the model.

Comparative Experiments with Model Pruning
Since there are some layers in the network architecture whose data are very important for the whole network, pruning these layers will lose the relevant data and lead to a significant degradation of the model performance.Therefore, before pruning the model, the model needs to be processed by layer hopping.In this paper, layer hopping was applied to the output layer of the detection Head network.
Then, the improved model was pruned, and the results of pruning are shown in Table 2, where the parameter speed_up was used to set the degree of pruning.The larger the speed_up, the larger the degree of pruning of the model.In Table 2, Parameters represents the number of model parameters, which reflect the computational size of the model; FLOPs indicates the complexity of the model.When speed_up was set to 2, the FLOPs of the model was reduced, and the computational amount was reduced by 65.2%, which significantly reduced the computational amount and complexity of the model.The FPS was also improved by 24.8%, and the mAP was only reduced by 0.002, which had a very small effect on the accuracy of the model.After increasing the speed_up parameter, the computation and parameter of the pruned model were further reduced, and the FPS was further improved.When speed_up was 2.5, the model improvement effect was the most balanced.The FPS was improved by 36.7%, the number of parameters was reduced by 71%, the FLOPs were reduced to 39.6% of the original, and the mAP value was only reduced by 0.003.Figure 11 demonstrates the comparison of each channel before and after pruning, with the orange color representing the channel that is not pruned and the red color representing the channel that is pruned.This indicates that there were many redundant parameters in the Backbone network.The pruning operation can remove the redundant parameters, reduce the model complexity and the risk of overfitting, and improve the interpretability of the model.The improvement of FPS is very important for real-time detection, and the pruned model could meet the requirements of real-time monitoring.

Comparative Experiments with Different Algorithms
To further validate the performance of the improved algorithm, it was compared with other target-detection algorithms, including YOLOv7-tiny [24], YOLOv6n [25], YOLOv5n, YOLOv3-tiny [26], YOLOv9t [27], YOLOv10n [28] under the same hardware and environment configuration.The detection results of different algorithms are shown in Table 3.Compared with other algorithms, MSH-YOLOv8 achieved better FLOPs, accuracy, and recall values with less computation consumption.Meanwhile, the mAP of the MSH-YOLOv8 was higher than YOLOv7-tiny, YOLOv6n, YOLOv5n, YOLOv3-tiny, YOLOv9, YOLOv10 with 0.203, 0.053, 0.146, 0.218, 0.002, and 0.042, respectively.Although the FPS of the proposed algorithm was not the highest, it could meet the requirement of real-time monitoring.Figure 12 shows the detection results of different algorithms.YOLOv3-tiny, YOLOv5n, and YOLO7-tiny failed to detect all the carbon traces, reflecting comparatively lower detection accuracy.Although YOLOv6n and YOLOv10 could detect all the carbon traces, their detection accuracies were relatively low and may miss or misdetect when facing more complicated carbon traces.To show the performance improvement of the models in this paper more clearly, the mAP curves of each model were plotted.As shown in Figure 13, compared with other models, the improved model MSH-YOLOv8 had a significant improvement in mAP.In summary, the model proposed in this paper had a significant improvement in performance.

Conclusions
(1) To improve the quality of the images suffering from the problems of darkness and fluctuation of supplementary light inside a transformer, an improved image-enhancement algorithm was proposed.It incorporated the white-balance algorithm into the MSRCR algorithm to enhance the brightness as well as the contrast of the captured images while overcoming the brightness overexposure and color distortion of the original algorithm.
(2) Aiming at the problem of misdetection and omission detection of carbon-trace defects under the complex transformer background, the novel MSH-YOLOv8 detection network was proposed.The SimAM attention mechanism was introduced into the Back- To show the performance improvement of the models in this paper more clearly, the mAP curves of each model were plotted.As shown in Figure 13, compared with other models, the improved model MSH-YOLOv8 had a significant improvement in mAP.In summary, the model proposed in this paper had a significant improvement in performance.To show the performance improvement of the models in this paper more clearly, the mAP curves of each model were plotted.As shown in Figure 13, compared with other models, the improved model MSH-YOLOv8 had a significant improvement in mAP.In summary, the model proposed in this paper had a significant improvement in performance.

Conclusions
(1) To improve the quality of the images suffering from the problems of darkness and fluctuation of supplementary light inside a transformer, an improved image-enhancement algorithm was proposed.It incorporated the white-balance algorithm into the MSRCR algorithm to enhance the brightness as well as the contrast of the captured images while overcoming the brightness overexposure and color distortion of the original algorithm.
(2) Aiming at the problem of misdetection and omission detection of carbon-trace defects under the complex transformer background, the novel MSH-YOLOv8 detection network was proposed.The SimAM attention mechanism was introduced into the Backbone of the YOLOv8 network, which improved the ability to extract the features of defective carbon traces of the transformers without introducing redundant computational parameters.The DyHead module was used to construct the framework of the self-attention dynamic detection Head.Compared to the original network, the proposed model achieved a 5.1% increase in precision, a 2.4% increase in recall, and a 3.7% increase in mAP, contributing to the improved recognition accuracy of carbon traces under the complex backgrounds inside the transformer.
(3) To enhance the recognition speed of the improved network and reduce the model parameters and complexity, the LAMP algorithm was utilized to perform pruning operations to reduce the redundant parameters in the model channels and enhance the detection efficiency of the model with minor loss of the model accuracy as much as possible.Finally, the number of parameters was reduced by 71%, and the FPS was improved by 36.7%, while the accuracy was only reduced by 0.3% to meet the requirements for transformer internal real-time monitoring requirements.
Construction and Image Preprocessing of Carbon-Trace Defects 3.1.Sample Library Construction of Typical Defects Because the types of insulation defects inside the actual transformer are abundant and the samples used for the training of the recognition model are scarce, this paper utilized the indoor test to reproduce the on-site defects, enriching the sample library of insulation defects inside the transformer and facilitating the training of the deep-learning-based target recognition model constructed in this paper.
Construction and Image Preprocessing of Carbon-Trace Def 3.1.Sample Library Construction of Typical Defects Because the types of insulation defects inside the actual transformer are ab and the samples used for the training of the recognition model are scarce, this pa lized the indoor test to reproduce the on-site defects, enriching the sample library lation defects inside the transformer and facilitating the training of the deep-l based target recognition model constructed in this paper.

Figure 6 .
Figure 6.The structure of the improved YOLOv8 Network.

Figure 6 .
Figure 6.The structure of the improved YOLOv8 Network.

Figure 8 .Figure 8 .
Figure 8. DyHead block.In this paper, the DyHead module was integrated into the detection Head network of Yolov8, which can be integrated into a target-detection Head by effectively combining multiple self-attentive attention mechanisms across feature layers, enabling it to learn the

Sensors 2024 ,
24,  x FOR PEER REVIEW 13 of 18 them for carbon-trace identification and localization.The results shown in Figure10illustrate the ability of the algorithm to effectively detect authentic carbon traces inside the transformers, even under complex background scenarios.This demonstrated the practical effectiveness of the algorithm proposed in this paper.

Figure 10 .
Figure 10.Detection performance of real transformer carbon traces.

Figure 10 .
Figure 10.Detection performance of real transformer carbon traces.

Figure 11 .
Figure 11.Comparison of channels before and after pruning.

Figure 13 .
Figure 13.mAP Curves of different detection models.

Figure 13 .( 1 )
Figure 13.mAP Curves of different detection models.6.Conclusions(1) To improve the quality of the images suffering from the problems of darkness and fluctuation of supplementary light inside a transformer, an improved image-enhancement algorithm was proposed.It incorporated the white-balance algorithm into the MSRCR algorithm to enhance the brightness as well as the contrast of the captured images while

Figure 13 .
Figure 13.mAP Curves of different detection models.

Table 1 .
Results of ablation experiments.

Table 2 .
Comparison of model pruning effects.

Table 3 .
Comparison of experimental results for different algorithms.